<template>
  <div class="homeIcons">
    <swiper :options="swiperOption">
         <swiper-slide v-for="(page , index) in pages" :key="index">
            <div class="icon"  v-for="item in page" :key="item.id">
                <div class="icon-img">
                <img
                    class="icon-img-content"
                    :src="item.imgUrl"
                >
                </div>
                <p class="icon-dsc">{{item.desc}}</p>
            </div>
         </swiper-slide>
    
    </swiper>
  </div>
</template>
<script>
export default {
  name: "homeIcons",
  data() {
    return {
       swiperOption:{
           autoplay:false
       }
    };
  },
  props:{
      iconslist:Array
  },
  computed:{
      pages(){
          const pages = [];
          this.iconslist.forEach((item,index)=>{
                const page = Math.floor(index/8);
                if(!pages[page]){
                    pages[page] = [];
                }
                pages[page].push(item);
          })
          return pages
      }
  }
};
</script>

<style>
.homeIcons .swiper-container{
  width: 100%;
  height: 0;
  overflow: hidden;
  padding-bottom: 50%;
}
.icon {
  float: left;
  width: 25%;
  height: 0;
  overflow: hidden;
  padding-bottom: 25%;
  position: relative;
}
.icon-img {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0.44rem;
  box-sizing: border-box;
  padding: 0.1rem;
}
.icon-img img.icon-img-content {
  display: block;
  margin: 0 auto;
  height: 100%;
}
.icon-dsc {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  line-height: 0.44rem;
  height: 0.44rem;
  color: #333;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow:ellipsis;
}
</style>